//-----------------------------------------------------------------------------
//   sk:codesamplers opengl version
//
//           Name: Vector3.h
//         Author: Kevin Harris
//  Last Modified: 02/01/05
//    Description: OpenGL compatible utility class for a 3D vector of floats
//                 NOTE: This class has been left unoptimized for readability.
//-----------------------------------------------------------------------------

#pragma once
#ifndef _VECTOR3_H_
#define _VECTOR3_H_

#include <cmath>

class Vector3
{
public:

    float x;
    float y;
    float z;

    Vector3();
    Vector3(float x_, float y_, float z_);
    void set(float x_, float y_, float z_);
	void set(Vector3& inVector);
    float length(void);
    void normalize(void);
	
    // Static utility methods
    static float distance(const Vector3 &v1, const Vector3 &v2);
    static float dotProduct(const Vector3 &v1,  const Vector3 &v2 );
	
    static Vector3 crossProduct(const Vector3 &v1, const Vector3 &v2);

    // Operators...
    Vector3 operator + (const Vector3 &other)
	{
		Vector3 vResult(0.0f, 0.0f, 0.0f);

		vResult.x = x + other.x;
		vResult.y = y + other.y;
		vResult.z = z + other.z;

		return vResult;
	}
    Vector3 operator - (const Vector3 &other)
	{
		Vector3 vResult(0.0f, 0.0f, 0.0f);

		vResult.x = x - other.x;
		vResult.y = y - other.y;
		vResult.z = z - other.z;

		return vResult;
	}
    Vector3 operator * (const Vector3 &other);
    Vector3 operator / (const Vector3 &other);

    Vector3 operator * (const float scalar);
    friend Vector3 operator * (const float scalar, const Vector3 &other);
    
    Vector3& operator = (const Vector3 &other);
    Vector3& operator += (const Vector3 &other);
    Vector3& operator -= (const Vector3 &other);

    Vector3 operator + (void) const;
    Vector3 operator - (void) const;
};


#endif // _VECTOR3F_H_
